<?php
//先安装工具吧==== OpenOffice，SWFTools，jodconverter

define("SWF_TOOLS_PATH","C:\\Program Files (x86)\\SWFTools");
define("OPEN_OFFICE_PATH","C:\\Program Files (x86)\\OpenOffice 4");
define("JOD_CONVERTER_JAR","C:\\softs\\jodconverter-2.2.2\\lib\\jodconverter-cli-2.2.2.jar");


//只有一个函数就是 exec($cmd $op).为什么不手动cmd呢，(额，只是为了增加代码练习量 O(∩_∩)O)

function pdf2swf($inFile,$outFile){
	$args = $inFile."  -o ".$outFile;
	if (isWindowOs()){
		$cmd = "cmd /c \"".SWF_TOOLS_PATH."\\pdf2swf.exe\" ". $args;
		$result = exec($cmd,$op);
		echo $result;
	}
}

function doc2pdf($inFile,$outFile){ //个人window环境使用jodconverter + openoffice +cmd （也有使用com + openoffice服务）  java -jar jodconverter-cli-2.2.2.jar 
	$cmd = "java -jar ".JOD_CONVERTER_JAR . " ".$inFile. " ".$outFile;
	$reult = exec($cmd,$op);
	echo $reult;
}

//soffice.exe  -headless -accept="socket,host=127.0.0.1,port=8100;urp;"
function startOpenOfficeService(){
	$args = " -headless -accept=\"socket,host=127.0.0.1,port=8100;urp;\"";  //汗！！！ cmd /c 执行传参数有点问题 ,去手动执行上面的cmd吧
	$cmd = "cmd /c \"".OPEN_OFFICE_PATH."\\program\\soffice.exe\"".$args;
	$result = exec($cmd,$op);
	echo $result;
}

function isWindowOS(){
	if (DIRECTORY_SEPARATOR=='/'){
		return false;
	}
	return true;
}

//pdf2swf("C:\\workspace\\2016.pdf","C:\\workspace\\20162.swf");
//doc2pdf("C:\\Users\\Administrator\\Desktop\\survey_api.docx","2016.pdf");
//cmd /c "C:\Program Files (x86)\OpenOffice 4\program\soffice.exe" -headless -accept="socket,host=127.0.0.1,port=8100;urp;"
//startOpenOfficeService();